const db = require('../../dataBase/index')
const { setRedisValue } = require("../../dataBase/redis")

const createUser = async (wechatOpenId) => {
    if (!wechatOpenId) return
    let querySql = `select * from user where wechat_uid="${wechatOpenId}"`
    const [res] = await db.execute(querySql)
    console.log('打印***res', res)
    if (res.length === 0) {
        let insertSql = `insert into user (wechat_uid,user_id) values ("${wechatOpenId}",1)`
        const [insertRes] = await db.execute(insertSql)
        console.log('打印***insertRes', insertRes)
        await setRedisValue(`${insertRes}`, `${openId},${accountName}`)
    }

}


module.exports = {
    createUser
}